<%@ page contentType="text/html;charset=UTF-8" %>
<%@include file="/WEB-INF/jsp/common/taglibs.jspf"%>
<es:contentHeader>
    <style>
        .col-sm-3 {width: 25%;float:left}
        .col-sm-9 {width: 75%;float:left}
        .form-horizontal .control-label {
            padding-top: 7px;
            margin-bottom: 0;
            text-align: right;
        }
        .ace-icon.icon_custom {top: 50%; margin-top: -8px;}
    </style>
</es:contentHeader>
<c:if test="${op eq '新增'}">
    <c:set var="icon" value="ace-icon fa fa-plus"/>
</c:if>
<c:if test="${op eq '修改'}">
    <c:set var="icon" value="ace-icon fa fa-pencil"/>
</c:if>
<c:if test="${op eq '删除'}">
    <c:set var="icon" value="ace-icon fa fa-trash-o"/>
</c:if>

<div class="page-content">
    <%@include file="nav.jspf"%>
    <es:showMessage/>

    <%--@elvariable id="m" type="com.bfl.sa.showcase.tree.entity.Tree"--%>
    <form:form id="editForm" method="post" commandName="m" cssClass="form-horizontal padding-vertical" enctype="multipart/form-data">
        <es:showGlobalError commandName="m"/>
        <form:hidden path="id"/>
        <form:hidden path="parentId"/>
        <form:hidden path="parentIds"/>
        <form:hidden path="weight"/>

        <div class="form-group">
            <form:label path="name" cssClass="col-sm-3 control-label no-padding-right">名称</form:label>
            <div class="col-sm-9">
                <form:input path="name" cssClass="form-control input-sm validate[required,custom[name]]" placeholder="小于50个字符"/>
            </div>
        </div>
        <div class="form-group">
            <form:label path="icon" cssClass="col-sm-3 control-label no-padding-right">图标</form:label>
            <div class="col-sm-9">
                <span class="input-icon input-icon-right block">
                    <form:input path="icon" cssClass="form-control" placeholder="点击选择图标" readonly="true"/>
                    <maintain:showIcon iconIdentity="${m.icon}"/>
                </span>
            </div>
        </div>
        <div class="form-group">
            <form:label path="show" cssClass="col-sm-3 control-label no-padding-right">是否显示</form:label>
            <div class="col-sm-9 radio">
                <form:radiobuttons path="show" items="${booleanList}" itemLabel="info" itemValue="value" cssClass="ace validate[required]"/>
            </div>
        </div>
        <div class="btn-group-sm text-right">
            <button type="submit" class="btn btn-info">
                <i class="${icon}"></i>${op}
            </button>
        </div>
    </form:form>
</div>

<es:contentFooter>
<%@include file="/WEB-INF/jsp/common/admin/import-maintain-js.jspf"%>
<script type="text/javascript">
    $(function () {
        <c:choose>
            <c:when test="${op eq '删除'}">
                //删除时不验证 并把表单readonly
                $.app.readonlyForm($("#editForm"), ${m.root});
            </c:when>
            <c:when test="${op eq '查看'}">
                $.app.readonlyForm($("#editForm"), true);
            </c:when>
            <c:otherwise>
                $.validationEngineLanguage.allRules.name = {
                    "regex": /^.{1,50}$/,
                    "alertText": "* 小于50个字符"
                };
                var validationEngine = $("#editForm").validationEngine();
                <es:showFieldError commandName="m"/>
            </c:otherwise>
        </c:choose>

        $.maintain.icon.initIconList($("#icon"));
    });
</script>
</es:contentFooter>
